var dataTree = null;
var Create_Table = null;
//列值
var colNames = [];
var colModel = [];


$(function () {
    //加载菜单树
    $.get("../customsettlement/getTree", function (r) {
        dataTree = r;
        ztree = $.fn.zTree.init($("#menuTree"), setting, r.list);
        //展开所有节点
        ztree.expandAll(true);

        /*if(roleId != null){
         vm.getRole(roleId);
         }*/
    });
    $("#jqGrid").jqGrid({
        url: '../persondispatch/list',
        postData: {"settlementId":'0'},
        datatype: "json",
        // datatype : "local",
        colModel: [{ label: 'id', name: 'id', index: 'id', key: true, hidden: true },
            { label: '结算点id', name: 'settlementId', index: 'settlement_id', hidden: true },
            { label: '公司名称', name: 'settlementname', index: 'settlement_name' },
            { label: '员工名称', name: 'name', index: 'name' },
            { label: '身份证', name: 'idno', index: 'idno' },
            { label: '人员id', name: 'personId', index: 'person_id', hidden: true },
            { label: '部门名称', name: 'department', index: 'department' },
            { label: '部门编号', name: 'departmentId', index: 'department_id', hidden:true },
            { label: '岗位', name: 'station', index: 'station'},
            { label: '派遣类型（1正常派遣，2临时劳务派遣）', name: 'dispatchType', index: 'dispatch_type'},
            { label: '合同id', name: 'contractId', index: 'contract_id'},
            { label: '档案状态:未接收、待接收', name: 'fileState', index: 'file_state'},
            { label: '档案id', name: 'archivesId', index: 'archives_id'},
            { label: '工伤:预申报,申报中，已申报', name: 'injury', index: 'injury'},
            { label: '工伤参保日期', name: 'injuryInsuredDate', index: 'injury_insured_date'},
            { label: '工伤退保日期', name: 'injurySurrenderDate', index: 'injury_surrender_date'},
            { label: '养老:预申报，申报中，已申报，不申报', name: 'pension', index: 'pension'},
            { label: '养老参保日期', name: 'pensionInsuredDate', index: 'pension_insured_date'},
            { label: '养老退保日期', name: 'pensionSurrenderDate', index: 'pension_surrender_date'},
            { label: '失业参保情况', name: 'unemployment', index: 'unemployment'},
            { label: '失业参保日期', name: 'unemploymentInsuredDate', index: 'unemployment_insured_date'},
            { label: '失业退保日期', name: 'unemploymentSurrenderDate', index: 'unemployment_surrender_date'},
            { label: '医保', name: 'medicare', index: 'medicare'},
            { label: '医保申报日期', name: 'medicareInsuredDate', index: 'medicare_insured_date'},
            { label: '医保退保日期', name: 'medicareSurrenderDate', index: 'medicare_surrender_date'},
            { label: '生育', name: 'maternity', index: 'maternity'},
            { label: '生育参保日期', name: 'maternityInsuredDate', index: 'maternity_insured_date'},
            { label: '生育退保日期', name: 'maternitySurrenderDate', index: 'maternity_surrender_date'},
            { label: '公积金', name: 'accumulationFund', index: 'accumulation_fund'},
            { label: '公积金参保日期', name: 'accumulationFundInsuredDate', index: 'accumulation_fund_insured_date'},
            { label: '公积金退保日期', name: 'accumulationFundSurrenderDate', index: 'accumulation_fund_surrender_date'},
            { label: '五险合一:未申报、预申报', name: 'fiveOneInsurance', index: 'five_one_insurance'},
            { label: '五险合一参保时间', name: 'fiveOneInsuredDate', index: 'five_one_insured_date'},
            { label: '五险合一退保时间', name: 'fiveOneSurrenderDate', index: 'five_one_surrender_date'},
            { label: '操作人', name: 'operator', index: 'operator'},
            { label: '操作日期', name: 'operationDate', index: 'operation_date'},
            { label: '不申报原因', name: 'noDeclareReason', index: 'no_declare_reason'},
            { label: '备注', name: 'remark', index: 'remark'},
            { label: '是否有效', name: 'enable', index: 'enable'},
            { label: '岗位级别', name: 'postLevel', index: 'post_level'},
            { label: '体检状态', name: 'physicalExaminationStatus', index: 'physical_examination_status',formatter:getDictInfo},
            { label: '派遣状态', name: 'dispatchStatus', index: 'dispatch_status',formatter:getDictInfo},
            { label: '是否上传到B1(0,未上传，1,已上传)', name: 'isupload', index: 'isupload'},
            { label: '是否华顺', name: 'isHuashun', index: 'isHuashun'},
            { label: '年龄', name: 'age', index: 'age'}
        ],
        viewrecords: true,
        height: $(window).height() * 0.6,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        //字段太多自动加载横轴滚动条
        shrinkToFit: false,
        autoScroll: false,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            //doResize();
            //显示grid底部滚动条
            //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" });
        }
    });

    Create_Table = {

        _init: function (id) {

            this.id = id;
            if (this.id === "jqGridPop") {
                this.jqGridPop();

            } else if (this.id === "jqGridPopSalary") {
                this.jqGridPopSalary();
            } else if (id === "jqGridPopPerson") {
                this.jqGridPopPerson();
            } else if(id === "jqGridPopRefund"){
                this.jqGridPopRefund();
            }
        },
        jqGridPop: function () {

            $("#jqGridPop").jqGrid({
                url: '../persondispatch/statement',
                editurl: 'clientArray',
                datatype: "json",
                postData: { 'settlementid': vm.unitId, "month": vm.q.month, "year": vm.q.year, "batch": vm.q.batch },
                //datatype: "local",
                colModel: [
                    { label: 'id', name: 'id', index: 'id', key: true },
                    { label: '结算点编号', name: 'settlementid', index: 'settlementid'},
                    { label: '劳务结算表汇总表ID', name: 'ssmid', index: 'ssmid'},
                    { label: '员工编号', name: 'empid', index: 'empid'},
                    { label: '员工状态', name: 'empstatus', index: 'empstatus'},
                    { label: '部门', name: 'department', index: 'department'},
                    { label: '姓名', name: 'name', index: 'name'},
                    { label: '身份证号', name: 'cardno', index: 'cardno'},
                    { label: '年', name: 'year', index: 'year'},
                    { label: '月', name: 'month', index: 'month'},
                    { label: '批次', name: 'batch', index: 'batch'},
                    { label: '实收总额', name: 'totalPaid', index: 'total_paid'},
                    { label: '单位应缴工伤部分(应收)', name: 'dwyjGongsYs', index: 'dwyj_gongs_ys'},
                    { label: '单位应缴养老部分(应收)', name: 'dwyjYanglYs', index: 'dwyj_yangl_ys'},
                    { label: '单位应缴失业部分(应收)', name: 'dwyjShiyYs', index: 'dwyj_shiy_ys'},
                    { label: '单位应缴医疗部分(应收)', name: 'dwyjYilYs', index: 'dwyj_yil_ys'},
                    { label: '单位应缴生育部分(应收)', name: 'dwyjShengyYs', index: 'dwyj_shengy_ys'},
                    { label: '单位应缴大病部分(应收)', name: 'dwyjDabYs', index: 'dwyj_dab_ys'},
                    { label: '单位应缴公积金部分(应收)', name: 'dwyjGongjjYs', index: 'dwyj_gongjj_ys'},
                    { label: '单位应缴养老部分(应收)', name: 'gryjYanglYs', index: 'gryj_yangl_ys'},
                    { label: '单位应缴失业部分(应收)', name: 'gryjShiyYs', index: 'gryj_shiy_ys'},
                    { label: '单位应缴医疗部分(应收)', name: 'gryjYilYs', index: 'gryj_yil_ys'},
                    { label: '单位应缴大病部分(应收)', name: 'gryjDabYs', index: 'gryj_dab_ys'},
                    { label: '单位应缴公积金部分(应收)', name: 'gryjGongjjYs', index: 'gryj_gongjj_ys'},
                    { label: '结算单位收管理费(实收)', name: 'jsdwGuanlifSs', index: 'jsdw_guanlif_ss'},
                    { label: '结算单位收工资(实收)', name: 'jsdwSalarySs', index: 'jsdw_salary_ss'},
                    { label: '结算单位收加班费(实收)', name: 'jsdwOvertimepaySs', index: 'jsdw_overtimepay_ss'},
                    { label: '结算单位工伤(实收)', name: 'jsdwGongsSs', index: 'jsdw_gongs_ss'},
                    { label: '结算单位养老(实收)', name: 'jsdwYanglSs', index: 'jsdw_yangl_ss'},
                    { label: '结算单位失业(实收)', name: 'jsdwShiySs', index: 'jsdw_shiy_ss'},
                    { label: '结算单位医疗(实收)', name: 'jsdwYilSs', index: 'jsdw_yil_ss'},
                    { label: '结算单位生育(实收)', name: 'jsdwShengySs', index: 'jsdw_shengy_ss'},
                    { label: '结算单位大病(实收)', name: 'jsdwDabSs', index: 'jsdw_dab_ss'},
                    { label: '结算单位公积金(实收)', name: 'jsdwGongjjSs', index: 'jsdw_gongjj_ss'},
                    { label: '结算单位意外(实收)', name: 'jsdwYiwaiSs', index: 'jsdw_yiwai_ss'},
                    { label: '结算单位单位小计(实收)', name: 'jsdwUnitsubtotalSs', index: 'jsdw_unitsubtotal_ss'},
                    { label: '结算个人养老(实收)', name: 'jsgrYanglSs', index: 'jsgr_yangl_ss'},
                    { label: '结算个人失业(实收)', name: 'jsgrShiySs', index: 'jsgr_shiy_ss'},
                    { label: '结算个人医疗(实收)', name: 'jsgrYilSs', index: 'jsgr_yil_ss'},
                    { label: '结算个人生育(实收)', name: 'jsgrShengySs', index: 'jsgr_shengy_ss'},
                    { label: '结算个人大病(实收)', name: 'jsgrDabSs', index: 'jsgr_dab_ss'},
                    { label: '结算个人公积金(实收)', name: 'jsgrGongjjSs', index: 'jsgr_gongjj_ss'},
                    { label: '结算个人个人小计(实收)', name: 'jsgrPersonsubtotalSs', index: 'jsgr_personsubtotal_ss'},
                    { label: '单位补差工商', name: 'bcdwGongsYs', index: 'bcdw_gongs_ys'},
                    { label: '单位补差养老', name: 'bcdwYanglYs', index: 'bcdw_yangl_ys'},
                    { label: '单位补差失业', name: 'bcdwShiyYs', index: 'bcdw_shiy_ys'},
                    { label: '单位补差医疗', name: 'bcdwYilYs', index: 'bcdw_yil_ys'},
                    { label: '单位补差生育', name: 'bcdwShengyYs', index: 'bcdw_shengy_ys'},
                    { label: '补差个人工伤', name: 'bcgrGongsYs', index: 'bcgr_gongs_ys'},
                    { label: '补差个人养老', name: 'bcgrYanglYs', index: 'bcgr_yangl_ys'},
                    { label: '补差个人失业', name: 'bcgrShiyYs', index: 'bcgr_shiy_ys'},
                    { label: '补差个人生育', name: 'bcgrShengyYs', index: 'bcgr_shengy_ys'},
                    { label: '补差个人医疗', name: 'bcgrYilYs', index: 'bcgr_yil_ys'},
                    { label: '结算其他-各项保险社保补差(实收)', name: 'jsqtAllbxbcSs', index: 'jsqt_allbxbc_ss'},
                    { label: '结算其他-个税(实收)', name: 'jsqtPersontaxSs', index: 'jsqt_persontax_ss'},
                    { label: '结算其他-福利费(实收)', name: 'jsqtFulifSs', index: 'jsqt_fulif_ss'},
                    { label: '结算其他-经济补偿(实收)', name: 'jsqtJingjibcSs', index: 'jsqt_jingjibc_ss'},
                    { label: '结算其他-劳保用品(实收)', name: 'jsqtLaobaoSs', index: 'jsqt_laobao_ss'},
                    { label: '结算其他-伙食(实收)', name: 'jsqtFoodSs', index: 'jsqt_food_ss'},
                    { label: '结算其他-工伤费用(实收)', name: 'jsqtGongsSs', index: 'jsqt_gongs_ss'},
                    { label: '结算其他-体检费用(实收)', name: 'jsqtTijianSs', index: 'jsqt_tijian_ss'},
                    { label: '结算其他-税金(实收)', name: 'jsqtTaxSs', index: 'jsqt_tax_ss'},
                    { label: '结算其他-社保补助(实收)', name: 'jsqtShebaobzSs', index: 'jsqt_shebaobz_ss'},
                    { label: '结算其他-工会医疗互助(实收)', name: 'jsqtGonghyilSs', index: 'jsqt_gonghyil_ss'},
                    { label: '结算其他-预留(实收)', name: 'jsqtRemarkoSs', index: 'jsqt_remarko_ss'},
                    { label: '结算其他-预留(实收)', name: 'jsqtRemarktSs', index: 'jsqt_remarkt_ss'},
                    { label: '结算其他-预留(实收)', name: 'jsqtRemarksSs', index: 'jsqt_remarks_ss'},
                    { label: '结算其他-预留(实收)', name: 'jsqtRemarkfSs', index: 'jsqt_remarkf_ss'},
                    { label: '结算其他-其他小计(实收)', name: 'jsqtSubtotalSs', index: 'jsqt_subtotal_ss'},
                    { label: '结算其他-说明(实收)', name: 'jsqtExplainSs', index: 'jsqt_explain_ss'},
                    { label: '基础信息-一审日期', name: 'basicFirstinstanceDate', index: 'basic_firstinstance_date'},
                    { label: '基础信息-一审人', name: 'basicFirstinstancePerson', index: 'basic_firstinstance_person'},
                    { label: '基础信息-二审日期', name: 'basicSecinstanceDate', index: 'basic_secinstance_date'},
                    { label: '基础信息-二审人', name: 'basicSecinstancePerson', index: 'basic_secinstance_person'},
                    { label: '结算其他-状态', name: 'basicStatus', index: 'basic_status'},
                    { label: '结算其他-未清金额', name: 'basicOutstandingAmount', index: 'basic_outstanding_amount'},
                    { label: '结算其他-税额', name: 'basicTaxAmount', index: 'basic_tax_amount'}
                ],
                //cellEdit:true,//是否开启单元格的编辑功能
                // cellsubmit:'remote',//or 'clientArray',remote代表每次编辑提交后进行服务器保存，clientArray只保存到数据表格不保存到服务器
                // cellurl:'xxx',//cellsubmit要提交的后台路径
                viewrecords: true,
                height: $(window).height() * 0.5,
                rowNum: 10,
                rowList: [10, 30, 50],
                rownumbers: true,
                rownumWidth: 25,
                autowidth: true,
                //loadonce: true,
                multiselect: true,
                //字段太多自动加载横轴滚动条
                shrinkToFit: false,
                autoScroll: false,
                pager: "#jqGridPagerPop",
                jsonReader: {
                    root: "page.list",
                    page: "page.currPage",
                    total: "page.totalPage",
                    records: "page.totalCount",
                },
                prmNames: {
                    page: "page",
                    rows: "limit",
                    order: "order"
                },
                gridComplete: function () {
                    //doResize();
                    //显示grid底部滚动条
                    //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" });
                }
            });


            this.init_colModel("jqGridPop");
        },

        jqGridPopSalary: function () {

            $("#jqGridPopSalary").jqGrid({
                url: '../persondispatch/salary',
                datatype: "json",
                colModel: [
                    { label: 'id', name: 'id', index: 'id', key: true },
                    { label: '', name: 'settlementid', index: 'settlementid', hidden: true},
                    { label: '状态', name: 'status', index: 'status'},
                    { label: '员工姓名', name: 'empname', index: 'empname'},
                    { label: '员工编号', name: 'empid', index: 'empid'},
                    { label: '身份证号', name: 'cardno', index: 'cardno'},
                    { label: '年', name: 'year', index: 'year'},
                    { label: '月', name: 'month', index: 'month'},
                    { label: '批次', name: 'batch', index: 'batch'},
                    { label: '应发工资-应发工资', name: 'yfgzSalary', index: 'yfgz_salary'},
                    { label: '应发工资-加班费', name: 'yfgzOuttimepay', index: 'yfgz_outtimepay'},
                    { label: '应发工资-社保补助', name: 'yfgzShebaobz', index: 'yfgz_shebaobz'},
                    { label: '应发工资-绩效工资', name: 'yfgzJixiaosalary', index: 'yfgz_jixiaosalary'},
                    { label: '应发工资-工龄工资', name: 'yfgzGonglsalary', index: 'yfgz_gonglsalary'},
                    { label: '应发工资-其他补助', name: 'yfgzOtherbz', index: 'yfgz_otherbz'},
                    { label: '应发工资-交通核报', name: 'yfgzJiaothb', index: 'yfgz_jiaothb'},
                    { label: '应发工资-通讯核报', name: 'yfgzTongxhb', index: 'yfgz_tongxhb'},
                    { label: '应发工资-其他核报', name: 'yfgzOtherhb', index: 'yfgz_otherhb'},
                    { label: '应发工资-午餐补助', name: 'yfgzWucanbz', index: 'yfgz_wucanbz'},
                    { label: '社保个人-工伤', name: 'sbgrGongs', index: 'sbgr_gongs'},
                    { label: '社保个人-养老', name: 'sbgrYangl', index: 'sbgr_yangl'},
                    { label: '社保个人-失业', name: 'sbgrShiy', index: 'sbgr_shiy'},
                    { label: '社保个人-医疗', name: 'sbgrYil', index: 'sbgr_yil'},
                    { label: '社保个人-公积金(正常部分)', name: 'sbgrGongjjZc', index: 'sbgr_gongjj_zc'},
                    { label: '社保个人-公积金补退(管理员工特有)', name: 'sbgrGongjjBt', index: 'sbgr_gongjj_bt'},
                    { label: '社保个人-大病', name: 'sbgrDab', index: 'sbgr_dab'},
                    { label: '社保补差-工商', name: 'sbbcGongs', index: 'sbbc_gongs'},
                    { label: '社保补差-养老', name: 'sbbcYangl', index: 'sbbc_yangl'},
                    { label: '社保补差-失业', name: 'sbbcShiy', index: 'sbbc_shiy'},
                    { label: '社保补差-医疗', name: 'sbbcYil', index: 'sbbc_yil'},
                    { label: '实发工资-手续费', name: 'sfgzShouxf', index: 'sfgz_shouxf'},
                    { label: '实发工资-扣税', name: 'sfgzTax', index: 'sfgz_tax'},
                    { label: '实发工资-实发工资', name: 'sfgzSalary', index: 'sfgz_salary'},
                    { label: '实发工资-经济补偿金', name: 'sfgzJinjbcj', index: 'sfgz_jinjbcj'},
                    { label: '实发工资-情况说明', name: 'sfgzRemark', index: 'sfgz_remark'},
                    { label: '其他扣款项目-劳务员工-个人往来', name: 'qtkkLwygGerenwl', index: 'qtkk_lwyg_gerenwl'},
                    { label: '其他扣款项目-劳务员工-派遣考核款', name: 'qtkkLwygPaiqkh', index: 'qtkk_lwyg_paiqkh'},
                    { label: '其他扣款项目-劳务员工-项目奖罚金', name: 'qtkkLwygProjectfk', index: 'qtkk_lwyg_projectfk'},
                    { label: '其他扣款项目-劳务员工-体检费', name: 'qtkkLwygTijian', index: 'qtkk_lwyg_tijian'},
                    { label: '其他扣款项目-劳务员工-水电费', name: 'qtkkLwygShuidf', index: 'qtkk_lwyg_shuidf'},
                    { label: '其他扣款项目-劳务员工-工会', name: 'qtkkLwygGonghui', index: 'qtkk_lwyg_gonghui'},
                    { label: '其他扣款项目-劳务员工-工会医疗互助', name: 'qtkkLwygGonghyilhz', index: 'qtkk_lwyg_gonghyilhz'},
                    { label: '其他扣款项目-劳务员工-伙食费', name: 'qtkkLwygFood', index: 'qtkk_lwyg_food'},
                    { label: '其他扣款项目-劳务员工-劳保用品', name: 'qtkkLwygLaobaoyp', index: 'qtkk_lwyg_laobaoyp'},
                    { label: '其他扣款项目-劳务员工-福利费', name: 'qtkkLwygFulif', index: 'qtkk_lwyg_fulif'},
                    { label: '其他扣款项目-劳务员工-补个税', name: 'qtkkLwygBupersontax', index: 'qtkk_lwyg_bupersontax'},
                    { label: '其他扣款项目-劳务员工-管理费', name: 'qtkkLwygManagementpay', index: 'qtkk_lwyg_managementpay'},
                    { label: '其他扣款项目-管理员工-工作服', name: 'qtkkGlygWorkclothes', index: 'qtkk_glyg_workclothes'},
                    { label: '其他扣款项目-管理员工-伙食费', name: 'qtkkGlygFood', index: 'qtkk_glyg_food'},
                    { label: '其他扣款项目-管理员工-个人往来', name: 'qtkkGlygGerenwl', index: 'qtkk_glyg_gerenwl'},
                    { label: '其他扣款项目-管理员工-奖罚款', name: 'qtkkGlygJiangfk', index: 'qtkk_glyg_jiangfk'},
                    { label: '其他扣款项目-管理员工-体检费', name: 'qtkkGlygTijian', index: 'qtkk_glyg_tijian'},
                    { label: '其他扣款项目-管理员工-工会', name: 'qtkkGlygGonghui', index: 'qtkk_glyg_gonghui'},
                    /*{ label: '其他-预留1', name: 'otherYuliu1', index: 'other_yuliu1'},
                    { label: '其他-预留2', name: 'otherYuliu2', index: 'other_yuliu2'},
                    { label: '其他-预留3', name: 'otherYuliu3', index: 'other_yuliu3'},
                    { label: '其他-预留4', name: 'otherYuliu4', index: 'other_yuliu4'},
                    { label: '其他-预留5', name: 'otherYuliu5', index: 'other_yuliu5'},*/
                    { label: '基础信息(税额)', name: 'basicTax', index: 'basic_tax'},
                    { label: '一审日期', name: 'basicFirstinstanceDate', index: 'basic_firstinstance_date'},
                    { label: '一审人', name: 'basicFirstinstancePerson', index: 'basic_firstinstance_person'},
                    { label: '二审日期', name: 'basicSecinstanceDate', index: 'basic_secinstance_date'},
                    { label: '二审人', name: 'basicSecinstancePerson', index: 'basic_secinstance_person'},
                    { label: '三审日期', name: 'basicThrinstanceDate', index: 'basic_thrinstance_date'},
                    { label: '三审人', name: 'basicThrinstancePerson', index: 'basic_thrinstance_person'},
                    { label: '状态', name: 'basicStatus', index: 'basic_status'}
                ],
                viewrecords: true,
                height: $(window).height() * 0.4,
                rowNum: 10,
                rowList: [10, 30, 50],
                rownumbers: true,
                rownumWidth: 25,
                autowidth: true,
                multiselect: true,
                //字段太多自动加载横轴滚动条
                shrinkToFit: false,
                autoScroll: false,
                pager: "#jqGridPagerPopSalary",
                jsonReader: {
                    root: "page.list",
                    page: "page.currPage",
                    total: "page.totalPage",
                    records: "page.totalCount"
                },
                prmNames: {
                    page: "page",
                    rows: "limit",
                    order: "order"
                },
                gridComplete: function () {
                    //隐藏grid底部滚动条
                    //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
                }
            });
            this.init_colModel("jqGridPopSalary");

        },

        jqGridPopPerson: function () {

            $("#jqGridPopPerson").jqGrid({
                url: '../socialsecuritypersonbasic/list',
                datatype: "json",
                colModel: [
                    { label: 'id', name: 'id', index: 'id', key: true,hidden:true },
                    { label: '员工姓名', name: 'name', index: 'name' },
                    { label: '', name: 'empid', index: 'empid',hidden:true },
                    { label: '结算点名称', name: 'settlementname', index: 'settlementname' },
                    { label: '', name: 'settlementid', index: 'settlementid',hidden:true },
                    { label: '年', name: 'year', index: 'year' },
                    { label: '月', name: 'month', index: 'month' },
                    { label: '养老保险基数', name: 'yanglbxBasic', index: 'yanglbx_basic' },
                    { label: '养老保险单位比例', name: 'yanglbxDwbl', index: 'yanglbx_dwbl' },
                    { label: '养老保险个人比例', name: 'yanglbxGrbl', index: 'yanglbx_grbl' },
                    { label: '医疗保险基数', name: 'yilbxBasic', index: 'yilbx_basic' },
                    { label: '医疗保险单位比例', name: 'yilbxDwbl', index: 'yilbx_dwbl' },
                    { label: '医疗保险个人比例', name: 'yilbxGrbl', index: 'yilbx_grbl' },
                    { label: '失业保险基数', name: 'shiybxBasic', index: 'shiybx_basic' },
                    { label: '失业保险单位比例', name: 'shiybxDwbl', index: 'shiybx_dwbl' },
                    { label: '失业保险个人比例', name: 'shiybxGrbl', index: 'shiybx_grbl' },
                    { label: '工伤保险基数', name: 'gongsbxBasic', index: 'gongsbx_basic' },
                    { label: '工伤保险单位比例', name: 'gongsbxDwbl', index: 'gongsbx_dwbl' },
                    { label: '工伤保险个人比例', name: 'gongsbxGrbl', index: 'gongsbx_grbl' },
                    { label: '生育保险基数', name: 'shengybxBasic', index: 'shengybx_basic' },
                    { label: '生育保险单位比例', name: 'shengybxDwbl', index: 'shengybx_dwbl' },
                    { label: '生育保险个人比例', name: 'shengybxGrbl', index: 'shengybx_grbl' },
                    { label: '公积金基数', name: 'gongjjBasic', index: 'gongjj_basic' },
                    { label: '公积金单位比例', name: 'gongjjDwbl', index: 'gongjj_dwbl' },
                    { label: '公积金个人比例', name: 'gongjjGrbl', index: 'gongjj_grbl' },
                    { label: '大病基数', name: 'dabinBasic', index: 'dabin_basic' },
                    { label: '大病单位比例', name: 'dabinDwbl', index: 'dabin_dwbl' },
                    { label: '大病个人比例', name: 'dabinGrbl', index: 'dabin_grbl' },
                    { label: '五险合一基数', name: 'totalBasic', index: 'total_basic' },
                    { label: '五险合一单位比例', name: 'totalDwbl', index: 'total_dwbl' },
                    { label: '五险合一个人比例', name: 'totalGrbl', index: 'total_grbl' },
                    { label: '是否五险合一(0,不是，五险分开记录，1,是，使用五险合一。)', name: 'istotal', index: 'istotal' }
                ],
                viewrecords: true,
                height: $(window).height() * 0.5,
                rowNum: 10,
                rowList: [10, 30, 50],
                rownumbers: true,
                rownumWidth: 25,
                autowidth: true,
                multiselect: true,
                pager: "#jqGridPagerPopPerson",
                //字段太多自动加载横轴滚动条
                shrinkToFit: false,
                autoScroll: false,
                jsonReader: {
                    root: "page.list",
                    page: "page.currPage",
                    total: "page.totalPage",
                    records: "page.totalCount"
                },
                prmNames: {
                    page: "page",
                    rows: "limit",
                    order: "order"
                },
                gridComplete: function () {
                    //隐藏grid底部滚动条
                    //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
                }
            });
            this.init_colModel("jqGridPopPerson");

        },

        init_colModel: function (id) {

            colModel = $("#" + id).jqGrid('getGridParam', 'colModel');
            var colNameobj = $("#" + id).jqGrid('getGridParam', 'colNames');
            for (var i = 2; i < colNameobj.length; i++) {
                colNames.push({
                    "id": i,
                    "value": colNameobj[i]
                });
            }

        },

        jqGridPopSocialSecurity: function(postData) {
            $("#jqGridPopSocialSecurity").jqGrid({
                url: '../socialsecuritytransaction/list',
                datatype: "json",
                postData: {
                    "confirmStatus": "0,1,2",
                    "processStatus": "0"
                },
                colModel: [
                    { label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden:true},
                    { label: '单位id', name: 'unitId', index: 'unit_id' ,hidden:true},
                    { label: '单位名称', name: 'settlement_name', index: 'settlement_name'},
                    { label: '员工姓名', name: 'name', index: 'name' },
                    { label: '员工id', name: 'employ_id', index: 'employ_id', hidden:true },
                    { label: '人员派遣id', name: 'person_dispatch_id', index: 'person_dispatch_id' ,hidden:true},
                    { label: '申报类型', name: 'declare_type', index: 'declare_type' ,formatter:getDictInfo},
                    { label: '保险类型', name: 'insurance_type', index: 'insurance_type' ,formatter:getDictInfo},
                    { label: '申报时间', name: 'declare_date', index: 'declare_date' },
                    { label: '申报人', name: 'declare_person', index: 'declare_person' },
                    { label: '备注', name: 'remark', index: 'remark' },
                    { label: '用工形式', name: 'employment_form', index: 'employment_form' },
                    { label: '异动原因', name: 'transaction_reason', index: 'transaction_reason' },
                    { label: '初审人', name: 'trial_judge', index: 'trial_judge' },
                    { label: '初审日期', name: 'Trial_date', index: 'Trial_date' },
                    { label: '终审人', name: 'chief_judge', index: 'chief_judge' },
                    { label: '终审日期', name: 'chief_date', index: 'chief_date' },
                    { label: '社保申报状态', name: 'process_status', index: 'process_status', formatter:getprocessStatus,unformat:ungetprocessStatus },
                    { label: '审核状态', name: 'confirm_status', index: 'confirm_status',  formatter:getconfirmStatus,unformat:ungetconfirmStatus},
                    { label: '退回说明', name: 'return_explain', index: 'return_explain' }
                ],
                viewrecords: true,
                height: $(window).height() * 0.4,
                rowNum: 10,
                rowList: [10, 30, 50],
                rownumbers: true,
                rownumWidth: 25,
                autowidth: true,
                multiselect: true,
                //字段太多自动加载横轴滚动条
                shrinkToFit: false,
                autoScroll: false,
                pager: "#jqGridPopSocialSecurityPager",
                jsonReader: {
                    root: "page.list",
                    page: "page.currPage",
                    total: "page.totalPage",
                    records: "page.totalCount"
                },
                prmNames: {
                    page: "page",
                    rows: "limit",
                    order: "order"
                },
                gridComplete: function() {
                    //隐藏grid底部滚动条
                    //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
                }
            });
        },

        jqGridPopRefund: function(){
            $("#jqGridPopRefund").jqGrid({
                url: '../socialsecuritypaydetail/getInOutList',
                datatype: "json",
                colModel: [
                    { label: 'id', name: 'id', index: 'id', key: true },
                    { label: '社保险种', name: 'socialSecurityType', index: 'social_security_type'},
                    { label: '责任部门', name: 'responsibilitydepartment', index: 'responsibilityDepartment'},
                    { label: '责任人', name: 'responsibilityperson', index: 'responsibilityPerson'},
                    { label: '单位名称', name: 'unitName', index: 'unit_name'},
                    { label: '姓名', name: 'name', index: 'name'},
                    { label: '身份证号', name: 'cardNo', index: 'card_no'},
                    { label: '年', name: 'year', index: 'year'},
                    { label: '月', name: 'month', index: 'month'},
                    { label: '方式', name: 'way', index: 'way'},
                    { label: '是否结转', name: 'isCarryOver', index: 'is_carry_over'},
                    { label: '基数', name: 'baseNum', index: 'base_num'},
                    { label: '单位比例', name: 'unitScale', index: 'unit_scale'},
                    { label: '个人比例', name: 'personScale', index: 'person_scale'},
                    { label: '单位应缴', name: 'unitPayable', index: 'unit_payable'},
                    { label: '个人应缴', name: 'personPayable', index: 'person_payable'},
                    { label: '应缴付款劳动局状态', name: 'payableState', index: 'payable_state'},
                    { label: '应缴补报单位', name: 'bubaoPayableUnit', index: 'bubao_payable_unit'},
                    { label: '应缴补报个人', name: 'bubaoPayablePerson', index: 'bubao_payable_person'},
                ],
                viewrecords: true,
                height: $(window).height()*0.5,
                rowNum: 10,
                rowList : [10,30,50],
                rownumbers: true,
                rownumWidth: 25,
                autowidth:true,
                multiselect: true,
                pager: "#jqGridPopRefundPager",
                //字段太多自动加载横轴滚动条
                shrinkToFit:false,
                autoScroll: false,
                jsonReader : {
                    root: "page.list",
                    page: "page.currPage",
                    total: "page.totalPage",
                    records: "page.totalCount"
                },
                prmNames : {
                    page:"page",
                    rows:"limit",
                    order: "order"
                },
                gridComplete:function(){
                    //隐藏grid底部滚动条
                    //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
                }
            });
        }

    };

  Create_Table.jqGridPopSocialSecurity({
                 "confirmStatus": "0,1,2",
                 "processStatus": "0"
   }); 

});


var setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "unitId",
            pIdKey: "unitCode",
            rootPId: null
        },
        key: {
            url: "nourl"
        }
    },
    check: {
        //enable: true,
        nocheckInherit: true
    },
    callback: {
        beforeClick: getCurrentNode
        //onClick : zTreeOnClick
    }
};

function getCurrentNode(treeId, treeNode) {
    curNode = treeNode;
    zTreeOnClick(curNode);
    /*beforeClick: function(treeId, treeNode) {
     var zTree = $.fn.zTree.getZTreeObj("#menuTree");
     if (treeNode.isParent) {
     zTree.expandNode(treeNode);
     return false;
     } else {
     demoIframe.attr("src",treeNode.file + ".html");
     return true;
     }
     }*/
};

function zTreeOnClick(treeNode) {
    //alert(treeNode.name);
    vm.showList = true;
    vm.unitId = treeNode.unitId;
    var page = $("#jqGrid").jqGrid('getGridParam', 'page');
    $("#jqGrid").jqGrid('setGridParam', {
        postData: {
            'settlementId': treeNode.unitId
        },
        page: page
    }).trigger("reloadGrid");
};
var ztree;
var vm = new Vue({
    el: '#rrapp',
    data: {
        q: {
            name: null,
            confirmDate: null,
            year: null,
            month: null,
            batch: null
        },
        showList: true,
        showRefund: true,
        showBusinessSS: true,
        showDispatch: true,
        title: null,
        personDispatch: {
            dispatchType: 0,
            entryDate: ''
        },
        role: {},
        unitId: null,
        archTypeList: {},
        operationList: {},
        empArchivesbaseRecord: {},
        empContract: {
            conStartTime: '',
            conEndTime: '',
            tryStartTime: '',
            tryEndTime: '',
            relieveOrEndDate: ''
        },
        //bxgsList: {},
        //sblxList: {},
        stationList: {},   //华顺内部岗位
        sysOfficeList: {}, //华顺部门
        bxxq: {},
        sbjsgl: {}, //商保
        //批量修改
        coll: 2,
        message2: '',
        //列数
        sites: colNames,
        socialSecurityPersonBasic: {},    //社保个人基数
        serviceSettlementMain: {},        //汇总/单位结算单
        checked:{
            gongShangONorOff:'0',
            gongShang:false,
            gongJijin:false,
            yanglao:false,
            yanglaoONorOff:'0',

            shiye:false,
            shiyeONorOff:'0',

            yiliao:false,
            yiliaoONorOff:'0',

            dabing:false,
            dabingONorOff:'0',
            dgongjijin:false,
            dgongjijinONorOff:'0',
        },
        costTypeList: {},
        costFuncList: {},
        refundContract: {
            gongs_type:'0'
        }, //退款协议
        refund: {}  //交退款
    },
    methods: {
        query: function () {
            vm.reload();
            $("#Tablepop").animate({
                left: '0px'
            });
        },
        add: function () {
            vm.showList = false;
            vm.title = "新增";
            vm.personDispatch = {};
            $("#confirmPop").animate({
                left: '0px'
            });

        },
        update: function (event) {
            var id = getSelectedRow();
            if (id == null) {
                return;
            }
            vm.showList = false;
            vm.title = "修改";
            $("#confirmPop").animate({
                left: '0px'
            });
            if (true) {
                $("#dropDown").show();
            } else {
                $("#dropDown").hide();
            }
            vm.getInfo(id)
        },
        saveOrUpdate: function (event) {
            var url = vm.personDispatch.id == null ? "../persondispatch/save" : "../persondispatch/update";
            $.ajax({
                type: "POST",
                url: url,
                contentType: "application/json",
                data: JSON.stringify(vm.personDispatch),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        del: function (event) {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }

            confirm('确定要删除选中的记录？', function () {
                $.ajax({
                    type: "POST",
                    url: "../persondispatch/delete",
                    contentType: "application/json",
                    data: JSON.stringify(ids),
                    success: function (r) {
                        if (r.code == 0) {
                            alert('操作成功', function (index) {
                                $("#jqGrid").trigger("reloadGrid");
                            });
                        } else {
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        beforeConfirm: function () {
            var rowDatas = vm.getPersonDispatchRows();
            var ageFlag = 0;
            var gsFlag = 'N';
            rowDatas.forEach(function(val,index){
                if(val.age>55){
                   ageFlag = 1;
                }
                if(val.isHuashun=='Y'){
                    gsFlag = 'Y';
                }
            });
            if(ageFlag==1){
                vm.bxxq = {};
                vm.showBusinessSS = false;
                vm.getListinfo();
            }
            if(gsFlag=='Y'){
                vm.stationList = {};
                vm.sysOfficeList = {};
                vm.showDispatch = false;
                vm.getSysOfficeList();
                vm.getListinfo();
            }

            $("#confirmPop").animate({
                left: '0px'
            });
        },
        changeDepartName: function(){
            var text = $("#departmentId").find("option:selected").text();
            vm.personDispatch.department = text;
        },
        confirm: function () {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            var params = new Object();
            params.entryDate = vm.personDispatch.entryDate;
            params.department = vm.personDispatch.department;
            params.station = vm.personDispatch.station;
            params.dispatchType = vm.personDispatch.dispatchType;
            params.ids = JSON.stringify(ids);
            $.ajax({
                type: "POST",
                url: "../persondispatch/confirm",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            $("#jqGrid").trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        fileTrans: function () {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            $.ajax({
                type: "POST",
                url: "../emparchivesbase/archivesManage",
                contentType: "application/json",
                data: JSON.stringify(ids),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            $("#jqGrid").trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        openSettlementWindow: function(){
            $("#settlementPop").animate({
                left: '0px'
            });
        },
        openWindow: function (gridP, tableP) {
            Create_Table._init(gridP);
            vm.sites = colNames;
            colModel = colModel;


            if(vm.unitId==null){
                alert("请先选中结算点");
                return;
            }

            if(gridP == 'jqGridPop'||gridP == 'jqGridPopSalary'){
                if(vm.q.year==''||vm.q.year==null){
                    alert("请先填写年份数据");
                    return;
                }
                if(vm.q.month==''||vm.q.month==null){
                    alert("请先填写月份数据");
                    return;
                }
                if(vm.q.batch==''||vm.q.batch==null){
                    alert("请先填写批次数据");
                    return;
                }
            }

            if(gridP == 'jqGridPop'){
                $.ajax({
                    type: "POST",
                    url: "../customsettlement/info/" + vm.unitId,
                    contentType: "application/json",
                    async:false,
                    success: function (r) {
                        //如果结算点配置为单位结算
                        if(r.customSettlement.settlementMode=='1'){
                            //vm.serviceSettlementMain =
                            var params = new Object();
                            params.index = r.customSettlement.areaBaseId;
                            params.year = vm.q.year;
                            params.month = vm.q.month;
                            $.ajax({
                                type: "POST",
                                url: "../servicesettlementmain/getSettlementmainInfo",
                                contentType: "application/json",
                                data: JSON.stringify(params),
                                async: false,
                                success: function (res) {
                                    vm.serviceSettlementMain = res.serviceSettlementMain;
                                }
                            });
                            vm.openSettlementWindow();
                            return;
                        }
                    }
                });
            }

            var page = $("#" + gridP).jqGrid('getGridParam', 'page');
            $("#" + gridP).jqGrid('setGridParam', {
                postData: {
                    'settlementid': vm.unitId,
                    "month": vm.q.month,
                    "year": vm.q.year,
                    "batch": vm.q.batch
                },
                page: page
            }).trigger("reloadGrid");
            $("#" + tableP).animate({
                left: '0px'
            });
        },
        openMonth: function () {
            $("#monthPop").animate({
                left: '0px'
            });
        },
        confirmMonth: function () {
            $("#monthPop").animate({
                left: '2000px'
            });

            this.openWindow('jqGridPopPerson', 'TablepopPerson');
        },
        <!-- 批量修改结算数据 start -->
        editTables: function (gridParam) {
            var grid = $("#" + gridParam); //jqGridPop
            var rowids = grid.jqGrid('getDataIDs');
            for (var j = 0; j < colModel.length; j++) {
                colModel[j].editable = true;
            }
            for (var i = 0; i < rowids.length; i++) {
                grid.jqGrid('editRow', rowids[i]);
            }
        },
        saveEdit: function (gridParam) {
            var grid = $("#" + gridParam); //jqGridPop
            var ids = grid.jqGrid('getDataIDs');

            for (var i = 0; i < ids.length; i++) {
                grid.jqGrid('saveRow', ids[i]);
            }

            var rowDatas = new Array();
            ids.forEach(function (val, index) {
                rowDatas[index] = grid.jqGrid("getRowData", val);
            });

            var url;
            if (gridParam == "jqGridPop") {
                url = "../persondispatch/saveDetail";
            } else if (gridParam == "jqGridPopSalary") {
                url = "../persondispatch/saveSalary";
            } else if (gridParam == "jqGridPopPerson") {
                url = "../socialsecuritypersonbasic/updatePersonSS";
            }
            $.ajax({
                type: "POST",
                url: url,
                contentType: "application/json",
                data: JSON.stringify(rowDatas),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            grid.trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });

        },
        //保存某列
        saveCell: function (id, inputid) {
            var grid = $("#" + id);
            var ids = grid.jqGrid('getDataIDs');
            var inputValue = document.getElementById(inputid).value;
            for (var i = 0; i < ids.length; i++) {

                $("#" + id).jqGrid("setCell", ids[i], colModel[this.coll].name, inputValue);

            }
            if (id == "jqGridPop") {
                jQuery("#jqGridPop").jqGrid('setGridParam', {
                    url: ""
                }).trigger("reloadGrid");
            } else if (id == "jqGridPopSalary") {
                jQuery("#jqGridPopSalary").jqGrid('setGridParam', {
                    url: ""
                }).trigger("reloadGrid");
            } else if (id == "jqGridPopPerson") {
                jQuery("#jqGridPopPerson").jqGrid('setGridParam', {
                    url: ""
                }).trigger("reloadGrid");
            }

        },


        <!-- 批量修改结算数据 end -->

        getInfo: function (id) {
            $.get("../persondispatch/info/" + id, function (r) {
                vm.personDispatch = r.personDispatch;
            });
        },
        getRole: function (roleId) {
            $.get(baseURL + "sys/role/info/" + roleId, function (r) {
                vm.role = r.role;

                //勾选角色所拥有的菜单
                var menuIds = vm.role.menuIdList;
                for (var i = 0; i < menuIds.length; i++) {
                    var node = ztree.getNodeByParam("menuId", menuIds[i]);
                    ztree.checkNode(node, true, false);
                }
            });
        },
        getMenuTree: function (roleId) {
            //加载菜单树
            $.get(baseURL + "sys/menu/perms", function (r) {
                ztree = $.fn.zTree.init($("#menuTree"), setting, r.menuList);
                //展开所有节点
                ztree.expandAll(true);

                if (roleId != null) {
                    vm.getRole(roleId);
                }
            });
        },
        reload: function (event) {
            $(".pop").animate({
                left: '2000px'
            });
            // $("#archPop").animate({left:'2000px'});
            // $("#contractPop").animate({left:'2000px'});
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                page: page
            }).trigger("reloadGrid");
        },
        clickmp: function () {
            ztree = $.fn.zTree.init($("#menuTreeScreen"), setting, dataTree.list);
            $("#pop").animate({
                left: '0px'
            });
            document.getElementById("leftDiv").className = "col-sm-12";
            document.getElementById("rigthMune").style.display = "none";
        },
        closePop: function () {

            document.getElementById("leftDiv").className = "col-sm-8";
            document.getElementById("rigthMune").style.display = "block";
            $("#pop").animate({
                left: '-3500px'
            });
        },
        closeTablePop: function (tableP) {
            colNames = [];
            colModel = [];

            $("#" + tableP).animate({
                left: '2500px'
            });

        },
        showtime: function (id) {

        },
        archFirstConfirm: function () {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }

            $.ajax({
                type: "POST",
                url: "../emparchivesbase/archivesManage",
                contentType: "application/json",
                data: JSON.stringify(ids),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            $("#jqGrid").trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        archTrans: function () {
            vm.archTypeList = {};
            vm.operationList = {};
            $("#archPop").animate({
                left: '0px'
            });
            this.getListinfo();
        },
        archConfirm: function () {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            var params = new Object();
            params.archivesbaseCategory = vm.empArchivesbaseRecord.archivesbaseCategory;
            params.operation = vm.empArchivesbaseRecord.operation;
            params.ids = JSON.stringify(ids);
            $.ajax({
                type: "POST",
                url: "../emparchivesbaserecord/archConfirm",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            $("#jqGrid").trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        openContractWindow: function () {
            vm.empContract.conStartTime = new Date();
            $("#contractPop").animate({
                left: '0px'
            });
        },
        contractConfirm: function () {
            console.log(vm.empContract);
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            var params = new Object();
            params.empContract = vm.empContract;
            params.ids = ids;
            $.ajax({
                type: "POST",
                url: "../empcontract/generatorContract",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            $("#jqGrid").trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        openBusinessSSConfirmWindow: function () {
            // vm.sblxList = {};
            // vm.bxgsList = {};
            vm.bxxq = {};
            $("#businessSSPop").animate({
                left: '0px'
            });
            this.getListinfo();
        },
        businessSSConfirm: function () {
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }
            var params = new Object();
            params.ids = ids.join(",");
            params.sbjsglId = vm.sbjsgl.sbjsglId;
            $.ajax({
                type: "POST",
                url: "../sbydgl/addSbyd",
                contentType: "application/json",
                data: JSON.stringify(params),
                dataType:"json",
                async:false,
                cache:false,
                success: function(r){
                    if(r.code === 0){
                        alert('操作成功', function(index){
                            utils.closeCurrentPage();
                        });
                    }else{
                        alert(r.msg);
                    }
                }
            });

        },
        declare: function (type, operation) {
            var ids = vm.selectRows("jqGridPopSocialSecurity");
            if (ids == null) {
                return;
            }
            var params = new Object();
            params.type = type;
            params.operation = operation;
            params.ids = ids;
            $.ajax({
                type: "POST",
                url: "../socialsecuritytransaction/updateStatus",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        //待申报
        waitrecheck:function(){
         var page = $("#jqGridPopSocialSecurity" ).jqGrid('getGridParam', 'page');
            $("#jqGridPopSocialSecurity").jqGrid('setGridParam', {
                postData: {
                    "confirmStatus": "0,1,2",
                    "processStatus": "0"
                },
                page: page
            }).trigger("reloadGrid");
        },
        //申报中
        rechecking:function(){

          var page = $("#jqGridPopSocialSecurity" ).jqGrid('getGridParam', 'page');
            $("#jqGridPopSocialSecurity").jqGrid('setGridParam', {
                postData: {
                    "confirmStatus": "0,1,2",
                    "processStatus": "1"
                }
            }).trigger("reloadGrid");

          
        }, 
        //已申报
        rechecked:function(){
                var page = $("#jqGridPopSocialSecurity").jqGrid('getGridParam', 'page');
                $("#jqGridPopSocialSecurity").jqGrid('setGridParam', {
                        postData: {
                            "confirmStatus": "0,1,2",
                            "processStatus": "2"
                           }
                }).trigger("reloadGrid");

        },
        //未申报
        norecheck:function(){
            var page = $("#jqGridPopSocialSecurity").jqGrid('getGridParam', 'page');
            $("#jqGridPopSocialSecurity").jqGrid('setGridParam', {
                postData: {
                    "confirmStatus": "0,1,2",
                    "processStatus": "4"
                    }
                }).trigger("reloadGrid");
        },
        //退保协议
        policyC:function(id){
            var pid = getSelectedRow();
            if (pid == null) {
                return;
            }
            $.get("../refund/getRefundInfoByDSId/" + pid+"?ts="+new Date(), function (r) {
                if(id=="policy"){
                    vm.refund = {};
                    vm.refund.name = r.map.name;
                    vm.refund.idno = r.map.idno;
                    vm.refund.sex = r.map.sex;
                    vm.refund.age = r.map.age;
                    vm.refund.settlementName = r.map.settlement_name;
                    vm.refund.empid = r.map.empid;
                    vm.refund.settlementId = r.map.settlement_id;
                    vm.refund.dutyPerson = r.map.duty_person;
                    vm.refund.dutyDepartment = r.map.duty_department;
                }else{
                    vm.refundContract = {};
                    vm.refundContract.name = r.map.name;
                    vm.refundContract.idno = r.map.idno;
                    vm.refundContract.sex = r.map.sex;
                    vm.refundContract.age = r.map.age;
                    vm.refundContract.settlementName = r.map.settlement_name;
                    vm.refundContract.empid = r.map.empid;
                    vm.refundContract.settlementId = r.map.settlement_id;
                    vm.refundContract.dutyPerson = r.map.duty_person;
                    vm.refundContract.dutyDepartment = r.map.duty_department;
                }

            });
            if(id=='policy'){
                vm.costFuncList = {};
                vm.costTypeList = {};
                this.getListinfo();
            }
            $("#"+id).animate({
                left: '0px'
            });

        },
        /*退款协议*/
        handleCheckedCitiesChange:function(event){
            if (event.target.checked) {
                $('.' + event.target.name).attr("disabled", false);
                if(event.target.name=='gongshang'){
                    vm.refundContract.gongsType = '0';
                }else if(event.target.name=='yanglao'){
                    vm.refundContract.yanglType = '0';
                }else if(event.target.name=='shiye'){
                    vm.refundContract.shiyType = '0';
                }else if(event.target.name=='yiliao'){
                    vm.refundContract.yilType = '0';
                }else if(event.target.name=='dabing'){
                    vm.refundContract.dabType = '0';
                }else if(event.target.name=='gongjijin'){
                    vm.refundContract.gongjjType = '0';
                }
            } else {
                $('.' + event.target.name).attr("disabled", true);
                if(event.target.name=='gongshang'){
                    vm.refundContract.gongsType = '1';
                }else if(event.target.name=='yanglao'){
                    vm.refundContract.yanglType = '1';
                }else if(event.target.name=='shiye'){
                    vm.refundContract.shiyType = '1';
                }else if(event.target.name=='yiliao'){
                    vm.refundContract.yilType = '1';
                }else if(event.target.name=='dabing'){
                    vm.refundContract.dabType = '1';
                }else if(event.target.name=='gongjijin'){
                    vm.refundContract.gongjjType = '1';
                }
            }
            // this.checkedCities = event.target.checked ? cityOptions : [];
            //this.isIndeterminate = false;
        },
        selCostType: function(val){
            var id = getSelectedRow();
            if (id == null) {
                return;
            }

            if(val.target.value =="costtype01"){ //交款
                $('#selCostFunc').attr("disabled", true);
                Create_Table._init("jqGridPopRefund");
                vm.showRefund = false;
                var page = $("#jqGridPopRefund").jqGrid('getGridParam', 'page');
                $("#jqGridPopRefund").jqGrid('setGridParam', {
                    postData: {
                        'settlementid': vm.unitId,
                        'id': id,
                        'type':'payment',
                    },
                    page: page
                }).trigger("reloadGrid");
            }else{
                $('#selCostFunc').attr("disabled", false);
            }

        },
        selCostFunc: function(val){
            var id = getSelectedRow();
            if (id == null) {
                return;
            }

            if(val.target.value == 'costfunc01'){ //协议退款
                Create_Table._init("jqGridPopRefund");
                vm.showRefund = false;
                var page = $("#jqGridPopRefund").jqGrid('getGridParam', 'page');
                $("#jqGridPopRefund").jqGrid('setGridParam', {
                    postData: {
                        'settlementid': vm.unitId,
                        'id': id,
                        'type':'inoutContact',
                    },
                    page: page
                }).trigger("reloadGrid");
            }else{  //其他退款
                Create_Table._init("jqGridPopRefund");
                vm.showRefund = false;
                var page = $("#jqGridPopRefund").jqGrid('getGridParam', 'page');
                $("#jqGridPopRefund").jqGrid('setGridParam', {
                    postData: {
                        'settlementid': vm.unitId,
                        'id': id,
                        'type':'inoutOther',
                    },
                    page: page
                }).trigger("reloadGrid");
            }
        },
        refund: function(){
            var rowDatas = vm.getRows();
            if (rowDatas == null) {
                return;
            }
            var pid = getSelectedRow();
            if (pid == null) {
                return;
            }
            var params = new Object();
            params.refund = vm.refund;
            params.rowdatas = rowDatas;
            params.pid = pid;
            $.ajax({
                type: "POST",
                url: "../refund/saveRefund",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        saverefundContract: function(){
            var pid = getSelectedRow();
            if (pid == null) {
                return;
            }

            var params = new Object();
            params.refundContract = vm.refundContract;
            params.pid = pid;
            $.ajax({
                type: "POST",
                url: "../refund/saveRefundContract",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            vm.reload();
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        getListinfo: function () {
            $.get("../persondispatch/getListinfo", function (r) {
                vm.archTypeList = r.archType;
                vm.operationList = r.operation;
                vm.costFuncList = r.costFunc;
                vm.costTypeList = r.costType;
                vm.bxxq = r.bxxq;
                vm.stationList = r.station;
            });
        },
        getSysOfficeList: function () {
            $.get("../persondispatch/getSysOffice", function (r) {
                vm.sysOfficeList = r.sysOfficeList;
            });
        },
        //选择多条记录
        selectRows: function (id) {
            var grid = $("#"+id);
            var rowKey = grid.getGridParam("selrow");
            if(!rowKey){
                alert("请选择一条记录");
                return ;
            }

            return grid.getGridParam("selarrrow");
        },
        getRows: function(){
            //选择多条记录
            var grid = $("#jqGridPopRefund");
            var rowKey = grid.getGridParam("selrow");
            if(!rowKey){
                alert("请选择一条记录");
                return ;
            }

            var ids = grid.getGridParam("selarrrow");
            var rowDatas = new Array();
            ids.forEach(function(val,index){
                rowDatas[index] = $("#jqGridPopRefund").jqGrid("getRowData",val);
            });
            return rowDatas;

        },
        getPersonDispatchRows: function(){
            //选择多条记录
            var grid = $("#jqGrid");
            var rowKey = grid.getGridParam("selrow");
            if(!rowKey){
                alert("请选择一条记录");
                return ;
            }

            var ids = grid.getGridParam("selarrrow");
            var rowDatas = new Array();
            ids.forEach(function(val,index){
                console.log("val:"+val+";index:"+index);
                rowDatas[index] = $("#jqGrid").jqGrid("getRowData",val);
            });
            return rowDatas;
        }

    },

    //选择下拉框事件 某一列处于编辑状态
    watch: {
        coll: function (val) {
            var grid = $("#" + Create_Table.id);
            var ids = grid.jqGrid('getDataIDs');

            for (var j = 0; j < colModel.length; j++) {
                if (j == val) {
                    colModel[j].editable = true;
                } else {
                    colModel[j].editable = false;
                }
            }
            for (var i = 0; i < ids.length; i++) {
                grid.jqGrid('editRow', ids[i]);
            }
        },
        serviceSettlementMain: {
            handler: function (val, oldval) {
                //养老保险
                this.serviceSettlementMain.jsgrYanglSs = this.$refs.jsgrYanglSsRs.value * this.$refs.gryjYanglYs.value;
                this.serviceSettlementMain.jsdwYanglSs = this.$refs.jsdwYanglSsRs.value * this.$refs.dwyjYanglYs.value;
                //工伤
                this.serviceSettlementMain.jsdwGongsSs = this.$refs.dwyjGongsYs.value * this.$refs.jsdwGongsSsRs.value;
                //this.serviceSettlementMain.jsgrGongsSs = this.$refs.gryjGongsYs.value * this.$refs.jsgrGongsSsRs.value;
                //失业
                this.serviceSettlementMain.jsdwShiySs = this.$refs.jsdwShiySsRs.value * this.$refs.dwyjShiyYs.value;
                this.serviceSettlementMain.jsgrShiySs = this.$refs.jsgrShiySsRs.value * this.$refs.gryjShiyYs.value;
                //生育
                this.serviceSettlementMain.jsdwShengySs = this.$refs.dwyjShengyYs.value * this.$refs.jsdwShengySsRs.value;
                //this.serviceSettlementMain.jsgrShengySs = this.$refs.gryjShengyYs.value * this.$refs.jsgrShengySsRs.value;
                //大病
                this.serviceSettlementMain.jsgrDabSs = this.$refs.gryjDabYs.value * this.$refs.jsgrDabSsRs.value;
                this.serviceSettlementMain.jsdwDabSs = this.$refs.dwyjDabYs.value * this.$refs.jsdwDabSsRs.value;
                //医疗 /....
                this.serviceSettlementMain.jsdwYilSs = this.$refs.dwyjYilYs.value * this.$refs.jsdwYilSsRs.value;
                this.serviceSettlementMain.jsgrYilSs = this.$refs.gryjYilYs.value * this.$refs.jsgrYilSsRs.value;
                //公积金
                this.serviceSettlementMain.jsdwGongjjSs = this.$refs.dwyjGongjjYs.value * this.$refs.jsdwGongjjSsRs.value;
                this.serviceSettlementMain.jsgrGongjjSs = this.$refs.gryjGongjjYs.value * this.$refs.jsgrGongjjSsRs.value;
            },
            deep: true
        }
    },

});


function getprocessStatus(cellvalue, options, rowObject){
    var html="";
    if(cellvalue=="0"){
        html="待申报";
    }else if(cellvalue=="1"){
        html="申报中";
    }else if(cellvalue=="2"){
        html="已申报";
    }else if(cellvalue=="3"){
        html="退回";
    }else if(cellvalue=="4"){
        html="不申报";
    }else if(cellvalue=="5"){
        html="重新申报";
    }else if(cellvalue=="6"){
        html="临时退保";
    }
    return html;
}
function ungetprocessStatus(cellvalue, options, rowObject){
    var html="";
    if(cellvalue=="待申报"){
        html="0";
    }else if(cellvalue=="申报中"){
        html="1";
    }else if(cellvalue=="已申报"){
        html="2";
    }else if(cellvalue=="退回"){
        html="3";
    }else if(cellvalue=="不申报"){
        html="4";
    }else if(cellvalue=="重新申报"){
        html="5";
    }else if(cellvalue=="临时退保"){
        html="6";
    }
    return html;
}

function getconfirmStatus(cellvalue, options, rowObject){
    var html="";
    if(cellvalue=="0"){
        html="未审核";
    }else if(cellvalue=="1"){
        html="初审";
    }else if(cellvalue=="2"){
        html="终审";
    }else if(cellvalue=="3"){
        html="反审";
    }else if(cellvalue=="4"){
        html="退回";
    }
    return html;
}
function ungetconfirmStatus(cellvalue, options, rowObject){
    var html="";
    if(cellvalue=="未审核"){
        html="0";
    }else if(cellvalue=="初审"){
        html="1";
    }else if(cellvalue=="终审"){
        html="2";
    }else if(cellvalue=="反审"){
        html="3";
    }else if(cellvalue=="退回"){
        html="4";
    }
    return html;
}